# Makefile for building test (C++ 程序)
CXX := g++
CXXFLAGS := -std=c++17 -Wall -Wextra -O2
LDFLAGS :=

SRC := test.cpp
OBJ := $(SRC:.cpp=.o)
TARGET := test

.PHONY: all clean run debug

all: $(TARGET)

$(TARGET): $(OBJ)
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

debug: CXXFLAGS := -std=c++17 -Wall -Wextra -g -O0
debug: clean $(TARGET)

run: $(TARGET)
	./$(TARGET)

clean:
	-rm -f $(OBJ) $(TARGET)
